﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IOBusiness;
using System.Data;
using System.Text;

namespace Indochinaodyssey.UserControl.NavigatorMenu
{
    public partial class MenuForProjectCruises : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = menu();
        }

        public string menu() {
            
            StringBuilder menu = new StringBuilder();
            menu.Append("<div id=\"id_div1\">");
            menu.Append("<ul>");
            menu.Append("<li><a href=\"Home.aspx\">Home</a></li>");
            menu.Append("<li><a href=\"HalongBay.aspx\">Halong bay</a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(TopMenu("5"));
            menu.Append("</ul>");
            menu.Append("</li>");
            menu.Append("<li><a href=\"HalongHotel.aspx\">Halong hotels</a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(TopMenu("6"));
            menu.Append("</ul>");
            menu.Append("</li>");
            menu.Append("<li><a href=\"News.aspx\">Travel News</a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(TopMenuTravel());
            menu.Append("</ul>");
            menu.Append("</li>");
            menu.Append("</ul>");
            menu.Append("</div>");
            return menu.ToString();
        }
       

         private string TopMenu(string type)
        {
            string sqlQuocGia = " Select ID,TieuDe from tblNews Where typeID="+type;
            clsBSDungChung bs = new clsBSDungChung();
            DataTable tbCountry = new DataTable();
            tbCountry = bs.GetDataTableSQL(sqlQuocGia, "tblNews");
            StringBuilder menu = new StringBuilder();
            for (int i = 0; i < tbCountry.Rows.Count; i++)
            {
                if(type=="5")
                    menu.Append("<li><a href=\"HalongBayDetail.aspx?ID=" + tbCountry.Rows[i]["ID"] + "\">" + tbCountry.Rows[i]["TieuDe"] + "</a></li>");
                if (type == "6")
                    menu.Append("<li><a href=\"HalongHotelDetail.aspx?ID=" + tbCountry.Rows[i]["ID"] + "\">" + tbCountry.Rows[i]["TieuDe"] + "</a></li>");

            }
           
            return menu.ToString();
        }

         private string TopMenuTravel()
         {
             string sqlQuocGia = "Select * from tblCateNew where id<>1";
             clsBSDungChung bs = new clsBSDungChung();
             DataTable tbCountry = new DataTable();
             tbCountry = bs.GetDataTableSQL(sqlQuocGia, "tblNews2");
             StringBuilder menu = new StringBuilder();
             for (int i = 0; i < tbCountry.Rows.Count; i++)
             {
                 menu.Append("<li><a href=\"News.aspx?cateid=" + tbCountry.Rows[i]["ID"] + "\">" + tbCountry.Rows[i]["TieuDe"] + "</a></li>");
             }

             return menu.ToString();
         }
    }
}